Uec3.companyconfigIndexModule = Ext.extend(Ext.app.Module, {
    id: 'companyconfig_index',
    permissionId:96,
    objsCollection:new Ext.util.MixedCollection(true),
    getObjByKey:function(key){
		return this.objsCollection.get(key);
	},
    
	view:function(id){
		var payInvoice_store=this.getObjByKey("store");
		var record=payInvoice_store.getById(id);
		var desktop =Uec3.App.getDesktop(); 
		desktop.launchWindowByParam("saleInvoice_operation",{id:id,winId:id}); 
	},
    getPanel:function(params) {
   	var module=this;
	var formPanel = new Ext.FormPanel({
		labelAlign : 'left',
		frame : true,
		height:200,
		labelWidth:70,
		labelStyle:'color:#ff3333;',
		items : [{
            xtype: 'compositefield',
            fieldLabel: '媒体价系数',
            //anchor    : '-20',
            // anchor    : null,
            //msgTarget: 'under',
            combineErrors: false,
            items: [
                {xtype: 'displayfield', value: '媒体价=成本价X系数'},
                {xtype: 'numberfield',  name: 'retailPrice', width: 100, allowBlank: false}
            ]
        },{
            xtype: 'compositefield',
            fieldLabel: '保险价系数',
            //anchor    : '-20',
            // anchor    : null,
            //msgTarget: 'under',
            combineErrors: false,
            items: [
                {xtype: 'displayfield', value: '保险价=成本价X系数'},
                {xtype: 'numberfield',    name: 'insurancePrice', width: 100, allowBlank: false}
            ]
        },{
            xtype: 'compositefield',
            fieldLabel: '最低价系数',
            combineErrors: false,
            
            // anchor    : null,
            //msgTarget: 'under',
            items: [
                {xtype: 'displayfield', value: '最低价=成本价X系数'},
                {xtype: 'numberfield',    name: 'minPrice', width: 100, allowBlank: false}
            ]
        },
        Uec3.App.dictionary.getCombo('partproperty_publicanLevel',{hiddenName:'publicanLevel',fieldLabel:'公开级别'})],       
        buttons: [
                             {
             	                text:"保存",
             	            	width:70,
             	            	height:20,
             	            	//style:'margin:0px 10px 0px 0px',
             	            	iconCls:'icon-save',
             	            	handler:function(){
             	            		Uec3.App.companyConfig.save(formPanel.getForm().getValues());
                         		}
                     		},{
             	                xtype:'spacer',
             	                width:20
             	                //flex:1
                             },{
             	                text:"恢复默认",
             	            	width:70,
             	            	height:20,
             	            	iconCls:'icon-restore',
             	            	handler:function(){
             	            		formPanel.form.setValues(Uec3.App.companyConfig.getDefaultData());
             	       			Ext.Msg.confirm('信息', '是否要保存?', function(btn) {
            						if (btn == 'yes') {
            							Uec3.App.companyConfig.save(formPanel.getForm().getValues());
            						}else{          							
            							formPanel.getForm().setValues(Uec3.App.companyConfig.getData());         							
            						}
            					});
                         		}
                     		},{
             	                xtype:'spacer',
             	                width:20
             	                //flex:1
                             },{
             	                text:"关闭",
             	            	width:70,
             	            	height:20,
             	            	iconCls:'icon-close',
             	            	handler:function(){
             	            		formPanel.ownerCt.close();
                         		}
                     		}
                     ]
	});

	module.objsCollection.add("formPanel",formPanel);
	
	return formPanel;
	},
	initEvent:function(){
		var edit_companyconfig_permissionId=10;
		var module=this;
		var win=module.getObjByKey("win");
		win.on('show',function(){
			var form=module.getObjByKey("formPanel").getForm();
			form.setValues(Uec3.App.companyConfig.getData());
			if(!Ext.CUR_APP.hasPermission(edit_companyconfig_permissionId)){
				form.findField("retailPrice").setDisabled(true);
				form.findField("insurancePrice").setDisabled(true);
				form.findField("minPrice").setDisabled(true);
				module.getObjByKey("formPanel").getComponent("buttons").destroy();
			}
		},module,{single:true});
	},
   createWindow : function(params){
   	  var windowId=this.id;
   	  if(params&&params.winId){
   	  	windowId+="_"+params.winId;
   	  }
      var desktop = Uec3.App.getDesktop();   
      var win = desktop.getWindowByUecId(windowId);
      if(!win){ 
      	 var module=this;
         win = desktop.createWindow({
            uecId: windowId,
            width: 330,
            height: 200,
            title:'公司常用系数配置',
            iconCls: 'acc-icon-saleInvoice',
            shim: false,
            moduleObj:module,
            resizable:false,
            constrainHeader: true,
            maximizable: false,
            layout: "fit", 
            items:[module.getPanel(params)],
            listeners:{
            /*	'resize':function(win,width,height){
            		var top=this.items.get(0).items.first();
            		var grid=this.items.get(0).items.last();
            		var winMinWidth=900;
            		var winMinHeight=440;
            		if(width<winMinWidth||height<winMinHeight){
            			win.setWidth(winMinWidth);
            			win.setHeight(winMinHeight);
            			grid.setHeight(winMinHeight-110);
            		}else{
            			grid.setHeight(height-110);
            		}
            	}*/
            }
         });
         module.objsCollection.add("win",win);
         module.initEvent();
      } 
      win.show();
   }
	});
